! USB Modem Mac OS X script for GSM GPRS/EDGE networks
! Copyright (c) 2006 Mobile Stream
! All rights reserved
!
! Version 1.30wm
!
! Initiating or answering a call
@ORIGINATE
@ANSWER
!
! Configure the serial port
note "Script v1.30wm" 3
note "Configuring the serial port" 3
serreset 115200, 0, 8, 1
hsreset 0 0 0 0 0 0
!
! Check the phone is responding
note "Checking the phone is responding" 3
settries 0
@LABEL 1
matchclr
matchstr 1 2 "OK\13\10"
write "AT\13"
matchread 30
inctries
iftries 3 101
jump 1
@LABEL 2
!
! Initialize the phone
note "Initializing the phone" 3
settries 0
@LABEL 3
matchclr
matchstr 1 4 "OK\13\10"
matchstr 2 101 "ERROR\13\10"
write "AT&F0E0V1S0=0\13"
matchread 30
inctries
iftries 3 101
jump 3
@LABEL 4
ifANSWER 21
!
! Ask for APN
ask 0 "Enter GPRS/EDGE access point name" 110
!
! Set the GPRS APN
note "Setting the GPRS APN"
settries 0
@LABEL 5
matchclr
matchstr 1 6 "OK\13\10"
matchstr 2 101 "ERROR\13\10"
write "AT+CGDCONT=1,\34IP\34,\34^*\34\13"
matchread 30
inctries
iftries 3 101
jump 5
@LABEL 6
!
! Make a call
note "Dialing ^1" 3
write "ATD^1\13"
!
! Parse connect responses
@LABEL 21
matchclr
matchstr 1 80 "RING\13\10"
matchstr 2 103 "ERROR\13\10"
matchstr 3 102 "NO DIALTONE\13\10"
matchstr 4 104 "BUSY\13\10"
matchstr 5 103 "NO CARRIER\13\10"
matchstr 6 105 "NO ANSWER\13\10"
matchstr 7 22 "CONNECT"
matchread 400
jump 105
!
! Normal exit after call
@LABEL 22
hsreset 0 1 0 0 0 0
exit 0
!
! Handle RING response
@LABEL 80
ifORIGINATE 21
!
! Answering a call
userhook 1
note "Answering a call" 3
write "ATA\13"
jump 21
!
! Terminating a call
@HANGUP
!
! Escape to command mode and hangup
note "Script v1.30wm" 3
note "Hanging up modem" 3
hsreset 0 0 0 0 0 0
settries 0
@LABEL 91
flush
matchclr
matchstr 1 92 "NO CARRIER\13\10"
matchstr 2 92 "OK\13\10"
matchstr 3 92 "ERROR\13\10"
matchstr 4 92 "0\13\10"
write "ATH\13"
matchread 30
DTRClear
pause 5
DTRSet
flush
inctries
iftries 3 101
jump 91
@LABEL 92
settries 0
!
! Reset modem
note "Resetting modem" 3
@LABEL 93
pause 2
matchclr
matchstr 1 94 "OK\13\10"
write "AT&F0E0V1S0=0\13"
matchread 30
inctries
iftries 3 93
jump 101
!
! Normal exit after hangup
@LABEL 94
exit 0
!
! Modem error; the modem is not responding
@LABEL 101
exit -6019
!
! No dial tone
@LABEL 102
exit -6020
!
! No carrier
@LABEL 103
exit -6021
!
! The line is busy
@LABEL 104
exit -6022
!
! No answer
@LABEL 105
exit -6023
!
! No APN is provided
@LABEL 110
exit -6005
